<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

<style type="text/css">
	*{margin:0;padding:0;}
	li{list-style:none;}
	.point{margin:20px;display:inline-block;}
	.point>span{margin-left:20px;color:orange;}
	.task_list{width:1000px;margin:20px auto 0;}
	.task_list li{height:80px;background:rgba(100,100,100,0.5);line-height:80px;border-radius:10px;margin-top:10px;}
	.task_list li span{float:left;margin-left:20px;font-family: '微软雅黑';}
	.task_list li a{float:right;width:120px;height:60px;background:#bbb;margin-top:10px;line-height:60px;text-align:center;border-radius:30px;color:white;font-weight: bold;font-family: '微软雅黑';text-decoration: none;}
	.task_list li p{text-align:center;font-family: '微软雅黑';color:white;}
	.task_list li a.finish{background:orange;cursor: pointer;}
	body>p{text-align:center;height:50px;line-height:50px;}
	p>span{padding:10px 20px;cursor:pointer;background:#ccc;font-family: '微软雅黑';}
	p>span.on{background:orange;color:white;}
	.comTasks{display:none;}
</style>

</head>

<body>
	<h1 class="point">用户当前积分<span id='point'><?php echo ($point); ?></span></h1>
	<p><span class="on" onclick="ing(this)">进行中</span><span onclick="com(this)">已完成</span></p>
	<div class="task_list" id="ing">
		<ul>
			<?php if(is_array($tasks)): $i = 0; $__LIST__ = $tasks;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i; if(!empty($v['task'])): ?><li><span><?php echo ($v['task']['task_name']); ?></span><a <?php if($v['user_task']['status'] == 1): ?>class="finish" onclick="reward(<?php echo ($v['user_task']['id']); ?>,<?php echo ($v['task']['id']); ?>)"<?php endif; ?>><?php if($v['user_task']['status'] == 1): ?>领取奖励<?php else: echo ($v['user_task']['finish']); ?>/<?php echo ($v['task']['count']); endif; ?></a><p>奖励<?php echo ($v['task']['reward']); ?>积分</p></li><?php endif; endforeach; endif; else: echo "" ;endif; ?>
		</ul>
	</div>
	<div class="task_list comTasks" id="comTasks">
		<ul>
			<?php if(is_array($comTasks)): $i = 0; $__LIST__ = $comTasks;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><li><span><?php echo ($v['task_name']); ?></span><a>已完成</a><p>奖励<?php echo ($v['reward']); ?>积分</p></li><?php endforeach; endif; else: echo "" ;endif; ?>
		</ul>
	</div>
</body>
<script type="text/javascript" src="/Public/Admin/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript">
	function ing(obj){
		$(obj).addClass('on');
		$(obj).next().removeClass('on');
		$('#ing').show();
		$('#comTasks').hide();
	}
	function com(obj){
		$(obj).addClass('on');
		$(obj).prev().removeClass('on');
		$('#ing').hide();
		$('#comTasks').show();
	}
	// 领取奖励
	function reward(user_task_id,task_id){
		$.post('<?php echo U('reward');?>',{user_task_id:user_task_id,task_id:task_id},function(status){
			if(status == 1){
				location.reload();
			}else{
				layer.msg('领取失败，请稍后重试！',{icon:5,time:1000});
			}
		});
	}
</script>

</html>